namespace Maple.Branch.IdentityServer.DomainTests
{
    using System;
    using EfCoreConfigurations;
    using TestBases;

    public abstract class IdentityServerDomainTestBase : IdentityServerTestBase<IdentityServerDomainTestModule>
    {
        protected virtual void UsingDbContext(Action<IIdentityServerDbContext> action)
        {
            using var dbContext = GetRequiredService<IIdentityServerDbContext>();

            action.Invoke(dbContext);
        }

        protected virtual T UsingDbContext<T>(Func<IIdentityServerDbContext, T> action)
        {
            using var dbContext = GetRequiredService<IIdentityServerDbContext>();

            return action.Invoke(dbContext);
        }
    }
}
